import request from '@/utils/request';

// 创建标题
export function createTitle(data) {
  return request(`/title/create`, {
    method: 'POST',
    body: JSON.stringify(data),
  });
}


// 获取标题
export function getTitles(data) {
  return request(`/title/query`);
}

// 删除标题
export function delTitle(_id) {
  return request(`/title/del?_id=${_id}`);
}
// 创建段落
export function createParagraph(data) {
  return request(`/paragraph/create`, {
    method: 'POST',
    body: JSON.stringify(data),
  });
}


// 获取指定段落
export function getParagraphs(id) {
  return request(`/paragraph/query?id=${id}`);
}

// 获取所有段落
export function getAllParagraphs() {
  return request(`/paragraph/query`);
}

// 删除段落
export function delParagraph(_id) {
  return request(`/paragraph/del?_id=${_id}`);
}

// 编辑段落
export function editParagraph(data) {
  return request(`/paragraph/edit`, {
    method: 'POST',
    body: JSON.stringify(data),
  });
}

// 后台自动创建标题和段落
export function autoGenerate(url) {
  return request(`/title/autoGenerate?url=${url}`);
}